export const deepCopy = (newObj, oldObj) => {
  for (const key in oldObj) {
    if (oldObj[key] instanceof Array) {
      deepCopy(newObj[key] = [], oldObj[key])
    } else if (oldObj[key] instanceof Object) {
      deepCopy(newObj[key] = {}, oldObj[key])
    } else {
      key === 'label' ? newObj.text = oldObj[key] : newObj[key] = oldObj[key]
    }
  }
}
export const areaList = (arr, needList) => {
  for (let i = 0; i < arr.length; i++) {
    if (!arr[i].children) {
      arr[i].children = []
    } else {
      for (let j = 0; j < arr[i].children.length; j++) {
        if (!arr[i].children[j].children) {
          arr[i].children[j].children = [{ text: '' }]
        }
      }
    }
  }
  for (let i = 0; i < arr.length; i++) {
    const o = {}
    deepCopy(o, arr[i])
    // console.log(o)
    needList.push(o)
  }
  return needList
}
